<template>
  <div class="right-chart-2">
    <div class="rc2-header">系统在线人数</div>

    <div class="rc2-chart-container">
      <dv-capsule-chart class="right" :config="config" />
    </div>
  </div>
</template>

<script>

import { getxyDayuv } from "@/api/metrics"
export default {
  name: 'RightChart2',
  data () {
    return {
      config: {
        data: [],
        colors: [
          '#1df106',
          '#eed810',
          '#08eecb',
          '#035cf3',
          '#c6f105',
          '#c308ee',
          '#060af1',
          '#964ee8'],
        unit: '人',
        showValue: true
      }
    }
  },
  mounted () {
    this.loadData()
    // eslint-disable-next-line no-unused-vars
    this.timer = setInterval(this.loadData, 1000 * 60 * 10)
  },
  beforeDestroy () {
    clearInterval(this.timer)
  },
  methods: {
    loadData: function () {
      getxyDayuv().then(res => {
          const { config } = this
          this.config.data = res.data.xyDayuv
          this.config = { ...this.config }// this.data = res
        })
        .catch(function (res) {
          console.log(res)
        })
    }
  }
}
</script>

<style lang="less">
.right-chart-2 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

.rc2-header {
  text-align: center;
  height: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  margin-bottom: 1px;
}

.rc2-chart-container {
  flex: 1;
  display: flex;
}

.left {
  width: 30%;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

.number {
  font-size: 34px;
  color: #096dd9;
  font-weight: bold;
  margin-bottom: 30px;
}
}

.right {
  flex: 1;
  padding-bottom: 20px;
  padding-right: 20px;
  box-sizing: border-box;
}
}
</style>
